﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace XboxOneDriverApp
{
    public partial class SteamFolders : Form
    {
        public SteamFolders()
        {
            InitializeComponent();
        }

        private void btn_browse_Click(object sender, EventArgs e)
        {
            using (FolderBrowserDialog dialog = new FolderBrowserDialog())
            {
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string folder = dialog.SelectedPath;
                    list_Folders.Items.Add(folder);
                    if (UserData.gameFolders == null)
                    {
                        UserData.gameFolders = new List<string>();
                    }
                    UserData.gameFolders.Add(folder);
                }
            }
        }

        private void btn_remove_Click(object sender, EventArgs e)
        {
            if (list_Folders.SelectedItem != null)
            {
                string p = (string)list_Folders.SelectedItem;
                UserData.gameFolders.Remove(p);
            }
        }

        private void SteamFolders_FormClosed(object sender, FormClosedEventArgs e)
        {
            using (FileStream str = new FileStream(MainForm.userFile, FileMode.Create))
            {
                UserData.Write(str);
            }
        }
    }
}
